// src/supabaseClient.js
import wxAuthClient from './wxAuthClient';
import { createClient } from '@supabase/supabase-js';

// 替换为你的 Supabase 项目 URL 和 API 密钥
const supabaseUrl = 'https://cnpmrhkszqkuroxflxap.supabase.co'; // 你的 Supabase URL
const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNucG1yaGtzenFrdXJveGZseGFwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzU3MTgyNzQsImV4cCI6MjA1MTI5NDI3NH0.ZjZ3rQkZ82fIPidOeFfJ_lwpbg7-zIvbMJVAD7z7Wb8'; // 你的 Supabase 匿名 API 密钥

class SupabaseClient {
  constructor() {
    this.client = createClient(supabaseUrl, supabaseKey);
    // this.signIn();
  }

  async signIn() {
    const wxUser = wxAuthClient.getUserLocal();
    const email = 'wxUserid1' + '@jishuba.cn';
    const password = 'abcd1234';
    // const { user, error } = await this.client.auth.signUp({
    //   email,
    //   password,
    // });
    const { user, error: signInError } = await this.client.auth.signInWithPassword({
      email,
      password,
    });
    if (signInError) {
      console.error('Error signing in:', signInError);
    } else {
      console.log('Signed in user:', user);
    }
    return user;
  }
}
const supabaseClient = new SupabaseClient();
export default supabaseClient;
